﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace ClumsyWordsWP8.ViewModels
{
    public class WordDefinitionViewModel : INotifyPropertyChanged
    {
        public WordDefinitionViewModel() 
        {
            //this.TermPropertiesList = new List<TermProperties>();
        }

        /// <summary>
        /// The actual word that is being defined.
        /// </summary>
        private string _term;
        public string Term 
        { 
            get { return this._term; } 

            set 
            { 
                this._term = value;
                NotifyPropertyChanged("Term");
            } 
        }

        /// <summary>
        /// A collection of all term properties objects.
        /// </summary>
        private List<Group<TermProperties, PartOfSpeech>> _termPropertiesList;
        public List<Group<TermProperties, PartOfSpeech>> TermPropertiesList 
        {
            get { return _termPropertiesList; }
            set 
            {
                this._termPropertiesList = value;
                NotifyPropertyChanged("TermPropertiesList");
            }
        }


        //TODO : Add IsEmpty Method
        public bool IsEmpty()
        {
            if (string.IsNullOrEmpty(this.Term)) return true;
            return false;
        }

        #region NotifyPropertyChanged Implementation
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }

    public class Group<T, U> : List<T>
    {
        public Group(U key, IEnumerable<T> items)
            : base(items)
        {
            this.Key = key;
        }

        public U Key
        {
            get;
            set;
        }
    }

}